/**
 * @(#)UserServiceImpl.java, 2017/12/16.
 * <p/>
 * Copyright 2017 Wangzx, Inc. All rights reserved.
 * WANGZX/CONFIDENTIAL. Use is subject to license terms.
 */
package org.wangzx.study.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.wangzx.study.meta.vo.UserVO;
import org.wangzx.study.service.UserService;

@Service("userService")
public class UserServiceImpl implements UserService {
    private static final Logger logger = LoggerFactory.getLogger(UserServiceImpl.class);

    @Override
    @Cacheable(value = "commonCache", key = "10001")
    public UserVO getUserVO() {
        return genVO();
    }

    @Override
    @CacheEvict(value = "commonCache", key = "10001")
    public boolean evictUserVO() {
        return true;
    }

    private UserVO genVO() {
        logger.info("gen VO");
        UserVO vo = new UserVO();
        vo.setName("Tom");
        vo.setId("10001");
        return vo;
    }
}
